﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using System.Reflection;

namespace CS_BEGINNER_TO_PROFICIENT.STD.ReflectionSTD
{
    public class AppConfig
    {
        public string ConnectionString { get; set; }
        public int Timeout { get; set; }
    }

    public class ReflectionSTDP4
    {
        public static void Execute()
        {
            string json = File.ReadAllText(@"./../../STD/ReflectionSTD/File/config.json");
            var config = JsonConvert.DeserializeObject<AppConfig>(json);

            var configType = typeof(AppConfig);
            var properties = configType.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (var prop in properties)
            {
                var value = prop.GetValue(config);
                Console.WriteLine($"{prop.Name}: {value}");
            }
        }
    }
}
